<template>
  <a-card :bordered='false'>

    <!-- 查询区域 -->
    <div class='table-page-search-wrapper'>
      <a-form layout='inline' @keyup.enter.native='searchQuery'>
        <a-row :gutter='24'>

          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item label='基地'>
              <j-dict-select-tag type="list" v-model="queryParam.sourceBase" :trigger-change="true" dictCode="t_flower_planting_base,name,id" placeholder="请选择基地"
              @change='baseChande'/>
            </a-form-item>
          </a-col>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item label='地块'>
              <j-dict-select-tag type="list" v-model="queryParam.sourceGreenhouse" :trigger-change="true" :dictCode="houseDicCode" placeholder="请选择地块"/>
            </a-form-item>
          </a-col>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item label='库房'>
              <a-input placeholder='请输入库房' v-model='queryParam.storehouse'></a-input>
            </a-form-item>
          </a-col>
          <template v-if='toggleSearchStatus'>

            <a-col :xl='6' :lg='7' :md='8' :sm='24'>
              <a-form-item label='批次'>
<!--                <a-input placeholder='批次' v-model='queryParam.productionId'></a-input>-->
                <j-dict-select-tag style='width: 100%'  placeholder="请选择批次" dict-code="t_flower_production,code,code" v-model="queryParam.productionId"></j-dict-select-tag>
              </a-form-item>
            </a-col>
            <a-col :xl='6' :lg='7' :md='8' :sm='24'>
              <a-form-item label='产品'>

                <j-dict-select-tag  v-model="queryParam.variety"  :triggerChange='true' dictCode='t_flower_variety_zz,name,id'
                                    placeholder='请输入产品'>
                </j-dict-select-tag>
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <span style='float: left;overflow: hidden;' class='table-page-search-submitButtons'>
              <a-button type='primary' @click='searchQuery' icon='search'>查询</a-button>
              <a-button type='primary' @click='searchReset' icon='reload' style='margin-left: 8px'>重置</a-button>
              <a @click='handleToggleSearch' style='margin-left: 8px'>
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class='table-operator'>
      <a-button @click='handleAdd' type='primary' icon='plus'>新增</a-button>
      <a-button type='primary' icon='download' @click="handleExportXls('毛产品管理')">导出</a-button>
      <a-upload name='file' :showUploadList='false' :multiple='false' :headers='tokenHeader' :action='importExcelUrl'
                @change='handleImportExcel'>
        <a-button type='primary' icon='import'>导入</a-button>
      </a-upload>
      <a-dropdown v-if='selectedRowKeys.length > 0'>
        <a-menu slot='overlay'>
          <a-menu-item key='1' @click='batchDel'>
            <a-icon type='delete' />
            删除
          </a-menu-item>
        </a-menu>
        <a-button style='margin-left: 8px'> 批量操作
          <a-icon type='down' />
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class='ant-alert ant-alert-info' style='margin-bottom: 16px;'>
        <i class='anticon anticon-info-circle ant-alert-icon'></i> 已选择 <a
        style='font-weight: 600'>{{ selectedRowKeys.length }}</a>项
        <a style='margin-left: 24px' @click='onClearSelected'>清空</a>
      </div>

      <a-table
        ref='table'
        size='middle'
        bordered
        rowKey='id'
        :columns='columns'
        :dataSource='dataSource'
        :pagination='ipagination'
        :loading='loading'
        class='j-table-force-nowrap'
        :rowSelection='{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}'
        @change='handleTableChange'>

        <span slot='action' slot-scope='text, record'>
          <a @click='handleEdit(record)'>编辑</a>

          <a-divider type='vertical' />
          <a-dropdown>
            <a class='ant-dropdown-link'>更多 <a-icon type='down' /></a>
            <a-menu slot='overlay'>
              <a-menu-item>
                <a-popconfirm title='确定删除吗?' @confirm='() => handleDelete(record.id)'>
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <flowerHarvestInfo-modal ref='modalForm' @ok='modalFormOk'></flowerHarvestInfo-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import FlowerHarvestInfoModal from './modules/FlowerHarvestInfoModal'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'

export default {
  name: 'FlowerHarvestInfoList',
  mixins: [JeecgListMixin],
  components: {
    FlowerHarvestInfoModal
  },
  data() {
    return {
      description: '毛产品管理管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        /*  {
               title: '主表id',
               align:"center",
               dataIndex: 'mainid'
              },*/
        {
          title: '基地',
          align: 'center',
          dataIndex: 'sourceBase_dictText'
        },
        {
          title: '地块',
          align: 'center',
          dataIndex: 'sourceGreenhouse_dictText'
        },
        {
          title: '库房',
          align: 'center',
          dataIndex: 'storehouse_dictText'
        },

        {
          title: '批次',
          align: 'center',
          dataIndex: 'productionId'
        },
        {
          title: '产品',
          align: 'center',
          dataIndex: 'variety_dictText'
        },

        {
          title: '采收数量',
          align: 'center',
          dataIndex: 'harvestCount'
        },
        {
          title: '单位',
          align: 'center',
          dataIndex: 'flowerPoleLength'
        },
        {
          title: '采摘日期',
          align: 'center',
          dataIndex: 'harvestTime'
        },
        {
          title: '创建人',
          align: 'center',
          dataIndex: 'createUser'
        }, {
          title: '创建时间',
          align: 'center',
          dataIndex: 'createTime'
        },
        {
          title: '更新人',
          align: 'center',
          dataIndex: 'updateUser'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/chvegetable/flowerHarvestInfo/list',
        delete: '/chvegetable/flowerHarvestInfo/delete',
        deleteBatch: '/chvegetable/flowerHarvestInfo/deleteBatch',
        exportXlsUrl: 'chvegetable/flowerHarvestInfo/exportXls',
        importExcelUrl: 'chvegetable/flowerHarvestInfo/importExcel'
      },
      houseDicCode :"t_flower_planting_greenhouse,name,id,parent_id='1'",
    }
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    baseChande() {
      delete this.queryParam.sourceGreenhouse
      if (this.queryParam.sourceBase) {
        this.houseDicCode = 't_flower_planting_greenhouse,name,id,parent_id=\'' + this.queryParam.sourceBase + '\''
      } else {
        this.houseDicCode = 't_flower_planting_greenhouse,name,id,parent_id=\'2\''
      }
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>